uninitialized constant Authorization::AasmRoles::AASM (NameError)
Reported by phipster | August 25th, 2008 @ 04:19 PM
Hi, I'm running into problems when trying to get restful_authentication with the --aasm option working. I am a Rails newbie. I performed the following steps from the the instructions at http://github.com/technoweenie/r... to create a sample site using restful authentication with AASM.
Installed the restful_authentication plugin:
git clone git://github.com/technoweenie/restful-authentication.git restful_authentication
Installed the rubyist-aasm gem following the instructions provided there, i.e.
sudo gem install rubyist-aasm
I believe the aasm gem was installed correctly, because I can load it from irb or script/console. I was also able to execute the test steps outlined here by Scott Barron with this result:irb(main):001:0> require 'rubygems' => true irb(main):002:0> require 'aasm' => true irb(main):003:0> class Conversation irb(main):004:1> include AASM irb(main):005:1> aasm_initial_state :new irb(main):006:1> aasm_state :new irb(main):007:1> aasm_state :read irb(main):008:1> aasm_event :view do irb(main):009:2* transitions :to => :read, :from => [:new] irb(main):010:2> end irb(main):011:1> end => #Proc:0xb7b3fd14@/usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.2/lib/aasm.rb:59 irb(main):012:0> Conversation.new.view! => true irb(main):013:>
Generated the restful auth code:
./script/generate authenticated user sessions --aasm
Updated routes.rb and environment.rb as directed
The following error stack was produced when I ran ./script/server (sorry it's so long). If I commented out the user_observer statement in environment.rb, the application started up OK, but died in User#new with the same error "uninitialized constant Authorization::AasmRoles::AASM":
=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails 2.1.0 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Exiting /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:275:in `load_missing_constant': uninitialized constant Authorization::AasmRoles::AASM (NameError) from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing' from /mnt/win/rails/t4h_promo/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb:11:in `included' from /mnt/win/rails/t4h_promo/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb:9:in `class_eval' from /mnt/win/rails/t4h_promo/vendor/plugins/restful_authentication/lib/authorization/aasm_roles.rb:9:in `included' from /mnt/win/rails/t4h_promo/app/models/user.rb:7:in `include' from /mnt/win/rails/t4h_promo/app/models/user.rb:7 from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_without_new_constant_marking' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_file' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:214:in `load_file' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:95:in `require_or_load' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:260:in `load_missing_constant' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/inflector.rb:283:in `constantize' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/string/inflections.rb:143:in `constantize' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:157:in `observed_class' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:183:in `observed_classes' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:166:in `initialize' from /usr/local/lib/ruby/1.8/singleton.rb:95:in `new' from /usr/local/lib/ruby/1.8/singleton.rb:95:in `instance' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:38:in `instantiate_observers' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:36:in `each' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/observer.rb:36:in `instantiate_observers' from /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:26:in `define_dispatcher_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:177:in `call' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:177:in `evaluate_method' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:161:in `call' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `run' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `each' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `send' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:90:in `run' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb:272:in `run_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:483:in `send' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:483:in `prepare_dispatcher' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:151:in `process' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `send' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `run' from /mnt/win/rails/t4h_promo/config/environment.rb:17 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:149:in `call' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:149:in `listener' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in `call' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/configurator.rb:50:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/command.rb:212:in `run' from /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:502:in `load' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/mongrel.rb:64 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' from /usr/local/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from ./script/server:3
Comments and changes to this ticket
-
sethbc August 27th, 2008 @ 11:05 PM
restful_authentication isn't pulling in the aasm gem. as a temporary workaround you can just put:
require 'aasm'
in ApplicationController in your application.rb
-
pjammer November 9th, 2008 @ 03:49 PM
thanks for the fix. Will restful_authentication be updated to pull in the 'aasm' gem from github? i get the same error but i'm using http://github.com/rubyist/aasm/t... as the gem source. i know in the readme, it mentions to use the original svn source.
could this be the cause of the error? if so, how can we get a fix into the code for this?
-
aaron January 21st, 2009 @ 03:58 PM
thanks for the tip seth! i bumped into the same problem as nerbie too. ^_^ now it's working
-
... February 5th, 2009 @ 03:11 PM
Thanks!! :D That really saved me a few hours... Kind of "dumb" that restful_auth's docs don't mention it... :/
-
wooki June 15th, 2009 @ 07:15 AM
- Tag changed from aasm, error to aasm, authentication, error, restful, restful_authentication
I had the same problem and the fix above worked fine, but later I came across the following which also did the trick (and might be a better fix)...
http://erikonrails.snowedin.net/?p=20
script/plugin install git://github.com/rubyist/aasm.git
-
bluefuton November 9th, 2009 @ 09:57 AM
- Assigned user cleared.
If you have the aasm gem installed, you can add
config.gem 'aasm'
to your environment.rb to fix this.
-
bluefuton November 9th, 2009 @ 09:58 AM
- Assigned user set to mrflip
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Restful Authentication Generator
This widely-used plugin provides a foundation for securely managing user
authentication:
* Login / logout
* Secure password handling
* Account activation by validating email
* Account approval / disabling by admin
* Rudimentary hooks for authorization and access control.
http://github.com/technoweenie/restful-authentication/tree